import { StroageUtil } from "../../../vv/utils/StroageUtil";
import { stroageKey } from "../../constants";

/**
 * 宠物管理
 */
export class Pet {
    private static _inst: Pet = null;
    public static get inst() {
        if (!this._inst) {
            this._inst = new Pet();
        }
        return this._inst;
    }

    //设置缓存
    public setCache(id: number, obj: any) {
        if (!obj) {
            StroageUtil.removeItem(stroageKey.pet + "_" + id);
            return;
        }
        StroageUtil.setValue(stroageKey.pet + "_" + id, obj);
    }

    //获取缓存
    public getCache(id: number) {
        return StroageUtil.getObject(stroageKey.pet + "_" + id);
    }
}
